<template>
	<view class="info_body" @click="godetail">
		<uni-card>
			<view class="delet" v-if="isclose" @click.stop="delet">
				x
			</view>
			<view class="info_bodyy">
				<view class="info_top">
					<view class="info_top_left">
						<view class="left">
							<u-avatar :src="avatar ?  avatar:''"></u-avatar>
						</view>
						<view class="right">
							<view class="names">
								{{nickname}}
							</view>
							<view class="positiosn">
								{{item.user_work}}
							</view>
						</view>
					</view>
					<view class="info_top_right">
						<text>{{item.money}}元/月</text>
					</view>
				</view>
			
			<view class="info_middle">
				<view class="left">
					<text>{{item.criticism_title}}</text>
				</view>
				<view class="right">
					{{compayname}}
				</view>
			</view>
			
			<view class="needlist">
				<view class="needlist_item">
				{{study.text}}
				</view>
				<view class="needlist_item">
				{{work_impreance.text}}
				</view>
			</view>
			<view class="bottom">
				<view class="time">
					{{times}}发布
				</view>
				<view class="eye">
					<u-icon name="eye"></u-icon><text>{{item.look_person}}人看过</text>
				</view>
				<view class="place">
				{{ip}}
				</view>
			</view>
			</view>
		</uni-card>
	</view>
</template>

<script>
	
	import {formatDate} from "@/utils/time.js"
import avatar from "../../uni_modules/uview-ui/libs/config/props/avatar";
	const obj=uniCloud.importObject("work_view")
	const db=uniCloud.database()
	import {getPro} from "@/utils/province.js"
	export default {
		name:"workinfo",
		data() {
			return {
				ip:'',
				compayname:'',
				studylist: [{
						text: '高中',
						id: 0
					},
					{
						text: '中专',
						id: 1
					},
					{
						text: '大专',
						id: 2
					},
					{
						text: '本科',
						id: 3
					},
					{
						text: '硕士',
						id: 4
					},
					{
						text: '博士',
						id: 5
					},
					{
						text: '不限',
						id: 6
					}
				],
				worktimestudylist: [
					{
						text: '在校生',
						id: 0
					},
				
					{
						text: '应届生',
						id: 1
					},
					{
						text: '1年内',
						id: 2
					},
					{
						text: '1-3年内',
						id: 3
					},
					{
						text: '3-5年内',
						id: 4
					},
					{
						text: '5年以上',
						id: 5
					},
					{
						text: '不限',
						id: 6
					}
				
				]
			};
		},
		computed:{
			avatar(){
					
				if(this.item.user_id){
					return  this.item.user_id[0].avatar
				}
			},
			nickname(){
				if(this.item.user_id){
					return  this.item.user_id[0].nickname
				}
			},
			study(){
				if(this.item){
					return  this.studylist[this.item.study]
				}
			},
			work_impreance(){
				if(this.item){
					return this.worktimestudylist[this.item.work_impreance]
				}
			},
			times(){
				if(this.item.publish_date){
					return formatDate(this.item.publish_date,1)
				}
			}
		},
		props:{
			item:{
				type:Object,
				default(){
					return {}
				}
			},
			isclose:{
				type:Boolean,
				default:false
			}
		},
		mounted() {
			this.getcompany()
			console.log(this.item.publish_ip,'666')
			getPro(this.item.publish_ip).then(res=>{
				console.log(res,this.item.publish_ip)
				this.ip=res
			})
		},
		methods:{
			//删除招聘信息
			delet(){
				this.$emit("deletezp",[this.item._id,this.item.criticism_title])
			},
		async 	getcompany(){
			// console.log(this.item.company_id,'ididi')
			await db.collection("argee").where({
					
			company_id:this.item.company_id
				}).get().then(res=>{
					console.log("那么到了",res)
					this.compayname=res.result.data[0].company_name
				})
			},
			godetail(){
				uni.navigateTo({
					url:`/pages-other/workInfo/workInfo?id=${this.item._id}`
				})
				obj.work_view(this.item._id)
				this.item.look_person=this.item.look_person+1
			}
		}
	}
</script>

<style lang="scss">

		.info_body{
			position: relative;
			.delet{
				position: absolute;
				right: 0;
				top:0;
				font-size: 30rpx;
				font-weight: 800;
			}
			.info_bodyy{
				.info_top{
					display: flex;
					justify-content: space-between;
					border-bottom: 2px solid #eee;
					.info_top_left{
						display: flex;
						.left{
							margin-right: 20rpx;
						}
						.right{
							.names{
								color: #1f1f1f;
								font-weight: 800;
								font-size: 35rpx;
								font-family: '楷体';
							}
							.positiosn{
								font-size: 25rpx;
								font-family: '宋体';
							}
						}
					}
					.info_top_right{
						display: flex;
						flex-direction: column;
						justify-content: center;
						font-size: 40rpx;
						color:#F9A826
					}
				}
			.info_middle{
				margin-top: 20rpx;
				display: flex;
				justify-content: space-between;
				.left{
					font-size: 35rpx;
					font-weight: 600;
					color: #000;
					font-family: "YouYuan";
				}
				.right{
					font-size: 30rpx;
				}
			}
			
			.needlist{
				margin-top: 20rpx;
				
				display: flex;
				flex-wrap: wrap;
				.needlist_item{
					margin-right: 10rpx;
					background-color: #76D7C4;
					color: #000;
					font-weight: 800;
					font-size: 20rpx;
					min-width: 120rpx;
					font-family: 'YouYuan';
					text-align: center;
					border-radius: 20rpx;
					margin-bottom: 20rpx;
					padding: 5rpx;
				}
			}
			.bottom{
				display: flex;
				justify-content: space-between;
				.time{
					font-size: 20rpx;
					font-family: '楷体';
				}
				.eye{
					display: flex;
					font-size: 20rpx;
					align-items: center;
					
				}
				.place{
					font-size: 30rpx;
					font-family: '宋体';
					font-weight: 600;
				}
				// margin-top: 10rpx;
			}
			
			}
			
		}
		
</style>